Checkpoint yahoo work. This gets messy because xml_format really wants C pointers...
authorRobert Lipe <robertlipe@gpsbabel.org>
Sun, 26 Jan 2020 10:42:29 +0000 (04:42 -0600)
committerRobert Lipe <robertlipe@gpsbabel.org>
Sun, 26 Jan 2020 10:42:29 +0000 (04:42 -0600)
CMakeLists.txt
GPSBabel.pro
Makefile.in
vecs.h
yahoo.cc
yahoo.h [new file with mode: 0644]

index 1a34bbaaf3ce162704854a7ae0fa8a9852cc1068..fc095fc4a859a6e3d607dbd29a3ef0bfa95c873f 100644 (file)
@@ -158,6 +158,7 @@ set(HEADERS
   vecs.h
   xcsv.h
   xmlgeneric.h
+  yahoo.h
   zlib/crc32.h
   zlib/deflate.h
   zlib/gzguts.h
index 89ed1eb3d22de2304a92ab9ad5bd336707572b1d..c09fa997ff2858d8c73dc21c8bf7b422f2399f73 100644 (file)
@@ -146,6 +146,7 @@ HEADERS =  \
        vecs.h \
        xcsv.h \
        xmlgeneric.h \
+       yahoo.h \
        zlib/crc32.h \
        zlib/deflate.h \
        zlib/gzguts.h \
index 90e2fd249e10123bd53ea3c6c7bfb4fe78875a8b..7d1a599e458ce9d56d7b12a8be766550f5f1a716 100644 (file)
@@ -1053,7 +1053,7 @@ xol.o: xol.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
   gbfile.h session.h src/core/datetime.h src/core/optional.h \
   garmin_tables.h jeeps/gpsmath.h jeeps/gpsport.h src/core/file.h \
   src/core/xmlstreamwriter.h xmlgeneric.h
-yahoo.o: yahoo.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+yahoo.o: yahoo.cc yahoo.h defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   xmlgeneric.h
 zlib/adler32.o: zlib/adler32.c zlib/zutil.h zlib/zlib.h zlib/zconf.h \
diff --git a/vecs.h b/vecs.h
index 6bb20cd57e2d94735929124bd7c86368391d4a18..eeb020180d5bddf6f3444c2050db741f86a0dd5d 100644 (file)
--- a/vecs.h
+++ b/vecs.h
@@ -30,6 +30,7 @@
 #include "format.h"
 #include "ggv_bin.h"
 #include "gpx.h"
+#include "yahoo.h"
 #include "legacyformat.h"
 
 
@@ -104,7 +105,7 @@ extern ff_vecs_t nmn4_vecs;
 #if CSVFMTS_ENABLED
 extern ff_vecs_t compegps_vecs;
 #endif // CSVFMTS_ENABLED
-extern ff_vecs_t yahoo_vecs;
+// extern ff_vecs_t yahoo_vecs;
 extern ff_vecs_t unicsv_vecs;
 extern ff_vecs_t gtm_vecs;
 extern ff_vecs_t gpssim_vecs;
@@ -309,7 +310,7 @@ private:
 #if CSVFMTS_ENABLED
   LegacyFormat compegps_fmt {compegps_vecs};
 #endif // CSVFMTS_ENABLED
-  LegacyFormat yahoo_fmt {yahoo_vecs};
+  YahooFormat yahoo_fmt;
   LegacyFormat unicsv_fmt {unicsv_vecs};
   LegacyFormat gtm_fmt {gtm_vecs};
   LegacyFormat gpssim_fmt {gpssim_vecs};
index 33401370b82b725eab59ea2cc7f0659014f04236..60abfb696276dafe35e8c7582eabd8765691e410 100644 (file)
--- a/yahoo.cc
+++ b/yahoo.cc
 
  */
 
+
 #include "defs.h"
+#include "yahoo.h"
 #include "xmlgeneric.h"
 #include <QtCore/QXmlStreamAttributes>
 
-static Waypoint* wpt_tmp;
-static char* as;
 
 #define MYNAME "yahoo"
 
-static
-QVector<arglist_t> yahoo_args = {
-  {
-    "addrsep", &as,
-    "String to separate concatenated address fields (default=\", \")",
-    ", ", ARGTYPE_STRING, ARG_NOMINMAX, nullptr
-  },
-};
-
-static xg_callback     wpt_s, wpt_lat, wpt_lon, wpt_e;
-static xg_callback     wpt_addr /*, wpt_city, wpt_state, wpt_zip, wpt_country*/;
-
+// static xg_callback  wpt_s, wpt_lat, wpt_lon, wpt_e;
+// static xg_callback  wpt_addr /*, wpt_city, wpt_state, wpt_zip, wpt_country*/;
+#if 0
 static xg_tag_mapping gl_map[] = {
   { wpt_s,     cb_start, "/ResultSet/Result" },
   { wpt_lat,   cb_cdata, "/ResultSet/Result/Latitude" },
@@ -52,54 +43,61 @@ static xg_tag_mapping gl_map[] = {
   { wpt_e,     cb_end,   "/ResultSet/Result" },
   { nullptr,   (xg_cb_type)0,         nullptr}
 };
+#endif
 
-static void
-yahoo_rd_init(const QString& fname)
+void YahooFormat() {printf("Ctor2\n");}
+void
+YahooFormat::rd_init(const QString& fname)
 {
   xml_init(fname, gl_map, nullptr);
 }
 
-static void
-yahoo_read()
+void
+YahooFormat::read()
 {
   xml_read();
 }
 
-static void
-yahoo_rd_deinit()
+void
+YahooFormat::rd_deinit()
 {
   xml_deinit();
 }
 
-void   wpt_s(xg_string, const QXmlStreamAttributes*)
+void
+YahooFormat::wpt_s(xg_string, const QXmlStreamAttributes*)
 {
   wpt_tmp = new Waypoint;
 }
 
-void   wpt_e(xg_string, const QXmlStreamAttributes*)
+void
+YahooFormat::wpt_e(xg_string, const QXmlStreamAttributes*)
 {
   waypt_add(wpt_tmp);
   wpt_tmp = nullptr;
 }
 
-void   wpt_lat(xg_string args, const QXmlStreamAttributes*)
+void
+YahooFormat::wpt_lat(xg_string args, const QXmlStreamAttributes*)
 {
   wpt_tmp->latitude = args.toDouble();
 }
 
-void   wpt_lon(xg_string args, const QXmlStreamAttributes*)
+void
+YahooFormat::wpt_lon(xg_string args, const QXmlStreamAttributes*)
 {
   wpt_tmp->longitude = args.toDouble();
 }
 
-void   wpt_addr(xg_string args, const QXmlStreamAttributes*)
+void
+YahooFormat::wpt_addr(xg_string args, const QXmlStreamAttributes*)
 {
   if (!wpt_tmp->notes.isEmpty()) {
     wpt_tmp->notes += as;
   }
   wpt_tmp->notes += args;
 }
-
+#if 0
 ff_vecs_t yahoo_vecs = {
   ff_type_file,
   { ff_cap_read, ff_cap_none, ff_cap_none },
@@ -115,3 +113,4 @@ ff_vecs_t yahoo_vecs = {
   , NULL_POS_OPS,
   nullptr
 };
+#endif
diff --git a/yahoo.h b/yahoo.h
new file mode 100644 (file)
index 0000000..e4f4645
--- /dev/null
+++ b/yahoo.h
@@ -0,0 +1,103 @@
+/*
+    Read Yahoo Geocoded files.
+
+    Copyright (C) 2002-2020 Robert Lipe, gpsbabel.org
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+ */
+#ifndef YAHOO_H_INCLUDED_
+#define YAHOO_H_INCLUDED_
+
+#include <QtCore/QString>               // for QString
+#include <QtCore/QStringList>           // for QStringList
+#include <QtCore/QXmlStreamAttributes>
+
+#include "defs.h"
+#include "format.h"                     // for Format
+#include "xmlgeneric.h"                     // for Format
+
+class YahooFormat : public Format
+{
+public:
+    YahooFormat() {printf("Ctor\n");}
+  QVector<arglist_t>* get_args() override
+  {
+    printf("Getting args\n");
+
+    return &yahoo_args;
+  }
+
+  ff_type get_type() const override
+  {
+    return ff_type_file;
+  }
+
+  QVector<ff_cap> get_cap() const override {
+    printf("Getting Cap\n");
+    return FF_CAP_RW_ALL;
+    //return { (ff_cap) ff_cap_read };
+  }
+
+  QString get_encode() const override {
+    return CET_CHARSET_ASCII;
+  }
+
+  int get_fixed_encode() const override {
+    return 0;
+  }
+
+  void rd_init(const QString&) override;
+  void read() override;
+  void rd_deinit() override;
+
+private:
+    Waypoint* wpt_tmp;
+    char* as;
+
+    QVector<arglist_t> yahoo_args = {
+      {
+        "addrsep", &as,
+        "String to separate concatenated address fields (default=\", \")",
+        ", ", ARGTYPE_STRING, ARG_NOMINMAX, nullptr
+      },
+    };
+    void wpt_s(const QString &, const QXmlStreamAttributes *);
+
+ void wpt_e(const QString &, const QXmlStreamAttributes *);
+ void wpt_lat(const QString &, const QXmlStreamAttributes *);
+ void wpt_lon(const QString &, const QXmlStreamAttributes *);
+ void wpt_addr(const QString &, const QXmlStreamAttributes *);
+ xg_tag_mapping gl_map[];
+
+#if 0
+      static xg_tag_mapping gl_map[] = {
+      { wpt_s, cb_start, "/ResultSet/Result" },
+      { wpt_lat,       cb_cdata, "/ResultSet/Result/Latitude" },
+      { wpt_lon,       cb_cdata, "/ResultSet/Result/Longitude" },
+      { wpt_addr,      cb_cdata, "/ResultSet/Result/Address" },
+      { wpt_addr,      cb_cdata, "/ResultSet/Result/City" },
+      { wpt_addr,      cb_cdata, "/ResultSet/Result/State" },
+      { wpt_addr,      cb_cdata, "/ResultSet/Result/Zip" },
+      { wpt_addr,      cb_cdata, "/ResultSet/Result/Country" },
+      { wpt_e, cb_end,   "/ResultSet/Result" },
+      { nullptr,       (xg_cb_type)0,         nullptr}
+      };
+#endif
+
+
+};
+
+#endif //  YAHOO_H_INCLUDED_